package com.snopy.collection.queue;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author snopy
 * @version 1.0.0
 * @classname DemoQueue
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/29 14:22
 */
@Slf4j
public class DemoQueue {
    public static void main(String[] args) {
        Queue<String> queue = new ArrayBlockingQueue<>(5);
        /*boolean flag = queue.add("Jack");
        //throw exception
        log.info("flag:{}",flag);
        String element = queue.element();
        log.info("element:{}",element);
        String str = queue.remove();
        log.info("str:{}",str);
        log.info("size:{}",queue.size());*/
        queue.offer("hello1");
        queue.offer("hello2");
        queue.offer("hello3");
        queue.offer("hello4");
        queue.offer("hello5");
        queue.offer("hello6");

        Deque<String> deque = new ArrayDeque<>(8);
        deque.offer("hello1");
        deque.offer("hello2");
        deque.offer("hello3");
        deque.offer("hello4");
        deque.offer("hello5");
        deque.offer("hello6");
        deque.offer("hello7");
        deque.offer("hello8");
        deque.addFirst("hello9");
        log.info("deque size:{}",deque.size());


    }
}
